package com.java.comprehensive.arithmetic.leecode.easy;

import java.util.Arrays;

/**
 * @Author: Dgg
 * @Date: 2022/1/6 21:53
 */
public class LeetCode_881 {
	public int numRescueBoats(int[] people, int limit) {
		Arrays.sort(people);
		int l = 0;
		int r = people.length - 1;
		int temp = 0;
		while (l < r) {
			if (people[l] + people[r] <= limit) {
				l++;
			}
			--r;
			temp++;
		}
		return temp;
	}
}
